const Lockr = function () {
    var instance;
    if (!window.localStorage) {
        console.warn('当前浏览器不支持LocalStorage,保存的内容将在下一次刷新时丢失');
        instance = {
            removeItem: function (key) {
                this[key] = undefined;
            }
        }
    } else {
        instance = window.localStorage;
    }

    const obj = {};
    obj.set = function (key, value) {
        if (value !== undefined) {
            instance[key] = value;
        } else {
            instance.removeItem(key);
        }
    }

    obj.get = function (key, def) {
        return instance[key] !== undefined ? instance[key] : def;
    }

    return obj;
}();